home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Imaging / Show Clipping Picture < prev    next >
Encoding:
Text File  |  1999-03-04  |  1.7 KB  |  74 lines  |  [TEXT/ToyS]

  1. property kasClippedPictType : "clpp"
  2. property kasClippingCreator : "drag"
  3. property kasPictureType : "PICT"
  4.  
  5.  
  6. on open fsObjs
  7.     repeat with fsObj in fsObjs
  8.         DoOne(fsObj)
  9.     end repeat
  10. end open
  11.  
  12.  
  13. on DoOne(fsObj)
  14.     set fInfo to basic info for fsObj
  15.     
  16.     -- Got a picture clipping file?
  17.     if (system type of fInfo is kasClippedPictType) and ¬
  18.         (system creator of fInfo is kasClippingCreator) then
  19.         
  20.         -- Load the picture
  21.         set myPict to the clipping from fsObj ¬
  22.             only returning the picture
  23.         
  24.         -- Add it to the clipboard        
  25.         clip myPict
  26.         
  27.         -- Get its info
  28.         set pinfo to the picture info for myPict
  29.         
  30.         -- Expand for info at bottom
  31.         set wBox to picture bounds of pinfo
  32.         set textTop to item 4 of wBox
  33.         set textMid to ((item 3 of wBox) - (item 1 of wBox)) / 2
  34.         set item 4 of wBox to textTop + 64
  35.         
  36.         -- Create display window
  37.         set pWindow to ¬
  38.             display drawing titled (catalog name of fInfo) ¬
  39.                 with dimensions {(item 3 of wBox) - (item 1 of wBox), (item 4 of wBox) - (item 1 of wBox)}
  40.         
  41.         -- Draw the picture
  42.         draw a picture into pWindow ¬
  43.             using data myPict
  44.         
  45.         -- Show the name
  46.         draw a string into pWindow ¬
  47.             offset by {textMid, textTop + 16} ¬
  48.             using data "File: " & (fsObj as string)
  49.         
  50.         -- Show the size
  51.         draw a string into pWindow ¬
  52.             offset by {textMid, textTop + 32} ¬
  53.             using data "Size: " & (picture size of pinfo)
  54.         
  55.         -- Show the dimensions
  56.         draw a string into pWindow ¬
  57.             offset by {textMid, textTop + 48} ¬
  58.             using data "Dims: " & DimsText(picture bounds of pinfo)
  59.         
  60.         -- Pause, then close
  61.         pause for 5 with seconds timing
  62.         display drawing pWindow with disposal
  63.     else
  64.         beep
  65.     end if
  66. end DoOne
  67.  
  68.  
  69. on DimsText(box)
  70.     set w to (item 3 of box) - (item 1 of box)
  71.     set h to (item 4 of box) - (item 2 of box)
  72.     return w & " x " & h
  73. end DimsText
  74.